<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    li {
      width: 500px;
      height: 30px;
      background-color: rgb(180, 207, 81);
      margin-top: 10px;
    }
  </style>
</head>

<body>
  <div id="app">
    <button @click="addLi">增加li</button>
    <ul>
      <li v-for="item in arr" :key="item">
        {{ item }}
      </li>
    </ul>
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        arr: [1, 2, 3, 4]
      },
      methods: {
        addLi() {
          this.arr.push(this.arr.length + 1);
          // console.log(document.querySelectorAll('ul>li'));
          /* const oul = document.querySelector('ul');
          oul.lastElementChild.style.background = 'red'; */
          this.$nextTick(() => {
            const oul = document.querySelector('ul');
            oul.lastElementChild.style.background = 'red';
            console.log(document.querySelectorAll('ul>li'));
          })
        }
      }
    })
  </script>
</body>

</html>